home *** CD-ROM | disk | FTP | other *** search
/ Internet Surfer 2.0 / Internet Surfer 2.0 (Wayzata Technology) (1996).iso / pc / text / mac / faqs.471 < prev    next >
Encoding:
Text File  |  1996-02-12  |  27.8 KB  |  803 lines

  1. Frequently Asked Questions (FAQS);faqs.471
  2.  
  3.  
  4.  
  5. 3) When Tim was one year old, Mary was three years older than Tim will be when
  6.    Jane is three times as old as Mary was six years before the time when Jane
  7.    was half as old as Tim will be when Mary will be ten years older than Mary
  8.    was when Jane was one-third as old as Tim will be when Mary will be three
  9.    times as old as she was when Jane was born.
  10.  
  11.                              HOW OLD ARE THEY NOW?
  12.  
  13. ==> logic/ages.s <==
  14. The solution: Tim is 3, Jane is 8, and Mary is 15.  A little grumbling
  15. is in order here, as clue number 1 leads to the situation a year and a
  16. half ago, when Tim was 1 1/2, Jane was 6 1/2, and Mary was 13 1/2.
  17.  
  18. This sort of problem is easy if you write down a set of equations.  Let
  19. t be the year that Tim was born, j be the year that Jane was born, m be
  20. the year that Mary was born, and y be the current year.  As indefinite
  21. years come up, let y1, y2, ... be the indefinite years.  Then the
  22. equations are
  23.  
  24.  
  25. y + 10 - t = 2 (y1 - j)
  26. y1 - m = 9 (y1 - t)
  27.  
  28. y - 8 - m = 1/2 (y2 - j)
  29. y2 - j = 1 + y3 - t
  30. y3 - m = 5 (y + 2 - t)
  31.  
  32. t + 1 - m = 3 + y4 - t
  33. y4 - j = 3 (y5 - 6 - m)
  34. y5 - j = 1/2 (y6 - t)
  35. y6 - m = 10 + y7 - m
  36. y7 - j = 1/3 (y8 - t)
  37. y8 - m = 3 (j - m)
  38.  
  39. t = y - 3
  40. j = y - 8
  41. m = y - 15
  42.  
  43. ==> logic/bookworm.p <==
  44. A bookworm eats from the first page of an encyclopedia to the last page.
  45. The bookworm eats in a straight line.  The encyclopedia consists of ten
  46. 1000-page volumes.  Not counting covers, title pages, etc., how many pages
  47. does the bookworm eat through?
  48.  
  49. ==> logic/bookworm.s <==
  50. On a book shelf the first page of the first volume is on the "inside"
  51.   __                             __
  52. B|  |                           |  |F
  53. A|1 |...........................|10|R
  54. C|  |                           |  |O
  55. K|  |                           |  |N
  56.  |  |                           |  |T
  57.   ----------------------------------
  58. so the bookworm eats only through the cover of the first volume, then 8 times
  59. 1000 pages of Volumes 2 - 9, then through the cover to the 1st page of Vol 10.
  60. He eats 8,000 pages.
  61.  
  62. ==> logic/boxes.p <==
  63. Which Box Contains the Gold?
  64.  
  65. Two boxes are labeled "A" and "B".  A sign on box A says "The sign
  66. on box B is true and the gold is in box A".  A sign on box B says
  67. "The sign on box A is false and the gold is in box A".  Assuming there
  68. is gold in one of the boxes, which box contains the gold?
  69.  
  70. ==> logic/boxes.s <==
  71. The problem cannot be solved with the information given.
  72.  
  73. The sign on box A says "The sign on box B is true and the gold is in box A".
  74. The sign on box B says "The sign on box A is false and the gold is in box A".
  75. The following argument can be made: If the statement on box A is true, then
  76. the statement on box B is true, since that is what the statement on box A
  77. says.  But the statement on box B states that the statement on box A is false,
  78. which contradicts the original assumption.  Therefore, the statement on box A
  79. must be false.  This implies that either the statement on box B is false or
  80. that the gold is in box B.  If the statement on box B is false, then either
  81. the statement on box A is true (which it cannot be) or the gold is in box B.
  82. Either way, the gold is in box B.
  83.  
  84. However, there is a hidden assumption in this argument: namely, that
  85. each statement must be either true or false.  This assumption leads to
  86. paradoxes, for example, consider the statement: "This statement is
  87. false."  If it is true, it is false; if it is false, it is true.  The
  88. only way out of the paradox is to deny that the statement is either true
  89. or false and label it meaningless instead.  Both of the statements on the
  90. boxes are therefore meaningless and nothing can be concluded from them.
  91.  
  92. In general, statements about the truth of other statements lead to
  93. contradictions.  Tarski invented metalanguages to avoid this problem.
  94. To avoid paradox, a statement about the truth of a statement in a language
  95. must be made in the metalanguage of the language.
  96.  
  97. Common sense dictates that this problem cannot be solved with the information
  98. given.  After all, how can we deduce which box contains the gold simply by
  99. reading statements written on the outside of the box?  Suppose we deduce that
  100. the gold is in box B by whatever line of reasoning we choose.  What is to stop
  101. us from simply putting the gold in box A, regardless of what we deduced?
  102. (cf. Smullyan, "What Is the Name of This Book?", Prentice-Hall, 1978,    #70)
  103.  
  104. ==> logic/calibans.will.p <==
  105.     ----------------------------------------------
  106.     |       Caliban's Will by M.H. Newman        |
  107.     ----------------------------------------------
  108.  
  109. When Caliban's will was opened it was found to contain the following
  110. clause:
  111.  
  112. "I leave ten of my books to each of Low, Y.Y., and 'Critic,' who are
  113. to choose in a certain order.
  114.  
  115. No person who has seen me in a green tie is to choose before Low.
  116.  
  117. If Y.Y. was not in Oxford in 1920 the first chooser never lent me
  118. an umbrella.
  119.  
  120. If Y.Y. or 'Critic' has second choice, 'Critic' comes before the one
  121. who first fell in love."
  122.  
  123. Unfortunately Low, Y.Y., and 'Critic' could not remember any of the
  124. relevant facts; but the family solicitor pointed out that, assuming the
  125. problem to be properly constructed (i.e. assuming it to contain no
  126. statement superfluous to its solution) the relevant data and order
  127. could be inferred.
  128.  
  129. What was the prescribed order of choosing; and who lent Caliban an
  130. umbrella?
  131.  
  132. ==> logic/calibans.will.s <==
  133. Let T be "person who saw Caliban in a green tie."
  134. Let U be "person who lent Caliban an umbrella."
  135. Then the data are:
  136. (1) No T chooses before Low.
  137. (2) Either Y.Y. was in Oxford in March 1920 or the first chooser is not
  138.     a U.
  139. (3) Either Low is second or Critic is not last.
  140.  
  141. Consider first (3)
  142. If it could be shown that Low is first, then from (3), Critic is not
  143. last and therefore is second; i.e. the order is Low, Critic, Y.Y.
  144.  
  145. Next (1)
  146. If both Critic and Y.Y. were T's would require Low first and (3) then
  147. gives the order Low-Critic-Y.Y., ie. (2) would be superfluous.  Hence
  148. Critic and Y.Y. are not both T's.
  149.  
  150. If neither Critic nor Y.Y. were a T, (1) would be trivially true for
  151. any ordering and therefore would give no information, i.e. would be
  152. superfluous.  Hence just one of Y.Y. and Critic is a T.  It follows
  153. that the only possible order in which Low is not first is:
  154.  
  155.     Not T, Low, T
  156.  
  157. Now (2)
  158. First if Y.Y was in Oxford in March 1920, nothing follows from (2)
  159. about the order and (2) is superfluous.  Hence Y.Y. was not in Oxford.
  160. If Low were a U he would not, by (2) come first, and so by (1) the
  161. order would be:
  162.  
  163.     Not T, Low, T
  164.  
  165. i.e. (1) and (2) alone would fix an order, and (3) would be superfluous.
  166. Hence Low is not a U.
  167.  
  168. It now follows, by the arguments just given for T's under (1) that just
  169. one of Y.Y. and Critic is a U.  If the same one is the T and the U (2)
  170. follows from (1) (since Low is not a U); i.e (2) is superfluous.  The
  171. situation is therefore:
  172.     T's: just one of Y.Y. and Critic; not Low
  173.     U's: the other one of Y.Y; not Low
  174. It now follows that "not T, Low, T" is impossible, for the "not T" is
  175. the "U" and therefore, by (2), is not first.  Hence Low is first, and
  176. (3) gives the order:
  177.     Low, Critic, Y.Y.
  178.  
  179. Finally, Y.Y. is a T, and Critic is a U.  For if Critic is a T, then
  180. by (1) Low precedes Critic and hence (3) allows only "Low, Critic, Y.Y";
  181. (2) is superfluous.  I.e. Critic (only) lent Caliban an umbrella.
  182.  
  183. The problem is from _Problems Omnibus_ by Hubert Phillips,
  184. Arco Publications, London, 1960.  Hubert Phillips was a noted puzzelist
  185. who contributed under his own name and the pseudonyms of "Caliban",
  186. "T.O. Hare", and "The Doc".
  187.  
  188. ==> logic/camel.p <==
  189. An Arab sheikh tells his two sons that are to race their camels to a
  190. distant city to see who will inherit his fortune.  The one whose camel
  191. is slower will win.  The brothers, after wandering aimlessly for days,
  192. ask a wiseman for advise.  After hearing the advice they jump on the
  193. camels and race as fast as they can to the city.  What did the wiseman
  194. say?
  195.  
  196. ==> logic/camel.s <==
  197. The wiseman tells them to switch camels.
  198.  
  199. ==> logic/centrifuge.p <==
  200. You are a biochemist, working with a 12-slot centrifuge.  This is a gadget
  201. that has 12 equally spaced slots around a central axis, in which you can
  202. place chemical samples you want centrifuged.  When the machine is turned on,
  203. the samples whirl around the central axis and do their thing.
  204.  
  205. To ensure that the samples are evenly mixed, they must be distributed in the
  206. 12 slots such that the centrifuge is balanced evenly.  For example, if you
  207. wanted to mix 4 samples, you could place them in slots 12, 3, 6 and 9
  208. (assuming the slots are numbered from 1 to 12 like a clock).
  209.  
  210. Problem:  Can you use the centrifuge to mix 5 samples?
  211.  
  212. ==> logic/centrifuge.s <==
  213. The superposition of any two solutions is yet another solution, so given
  214. that the factors > 1 of 12 (2, 3, 4, 6, 12) are all solutions, the
  215. only thing to check about, for example, the proposed solution 2+3 is
  216. that not all ways of combining 2 & 3 would have centrifuge tubes
  217. from one subsolution occupying the slot for one of the tubes in
  218. another solution.  For the case 2+3, there is no problem:  Place 3
  219. tubes, one in every 4th position, then place the 4th and 5th
  220. diametrically opposed (each will end up in a slot adjacent to one of
  221. the first 3 tubes).  The obvious generalization is, what are the
  222. numbers of tubes that cannot be balanced?  Observing that there are
  223. solutions for 2,3,4,5,6 tubes and that if X has a solution, 12-X has
  224. also one (obtained by swapping tubes and holes), it is obvious that
  225. 1 and 11 are the only cases without solutions.
  226.  
  227. Here is how this problem is often solved in practice:  A dummy tube
  228. is added to produce a total number of tubes that is easy to balance.
  229. For example, if you had to centrifuge just one sample, you'd add a
  230. second tube opposite it for balance.
  231.  
  232. ==> logic/children.p <==
  233. A man walks into a bar, orders a drink, and starts chatting with the
  234. bartender.  After a while, he learns that the bartender has three
  235. children.  "How old are your children?" he asks.  "Well," replies the
  236. bartender, "the product of their ages is 72."  The man thinks for a
  237. moment and then says, "that's not enough information."  "All right,"
  238. continues the bartender, "if you go outside and look at the building
  239. number posted over the door to the bar, you'll see the sum of the
  240. ages."  The man steps outside, and after a few moments he reenters and
  241. declares, "Still not enough!"  The bartender smiles and says, "My
  242. youngest just loves strawberry ice cream."
  243.  
  244. How old are the children?
  245.  
  246. A variant of the problem is for the sum of the ages to be 13 and the
  247. product of the ages to be the number posted over the door.  In this
  248. case, it is the oldest that loves ice cream.
  249.  
  250. Then how old are they?
  251.  
  252.  
  253. ==> logic/children.s <==
  254. First, determine all the ways that three ages can multiply together to get 72:
  255.  
  256. 72  1  1        (quite a feat for the bartender)
  257. 36  2  1
  258. 24  3  1
  259. 18  4  1
  260. 18  2  2
  261. 12  6  1
  262. 12  3  2
  263. 9  4  2
  264. 9  8  1
  265. 8  3  3
  266. 6  6  2
  267. 6  4  3
  268.  
  269. As the man says, that's not enough information; there are many possibilities.
  270. So the bartender tells him where to find the sum of the ages--the man now knows
  271. the sum even though we don't.  Yet he still insists that there isn't enough
  272. info.  This must mean that there are two permutations with the same sum;
  273. otherwise the man could have easily deduced the ages.
  274.  
  275. The only pair of permutations with the same sum are 8 3 3 and 6 6 2, which both
  276. add up to 14 (the bar's address).  Now the bartender mentions his
  277. "youngest"--telling us that there is one child who is younger than the other
  278. two.  This is impossible with 8 3 3--there are two 3 year olds.  Therefore the
  279. ages of the children are 6, 6, and 2.
  280.  
  281. Pedants have objected that the problem is insoluble because there could be
  282. a youngest between two three year olds (even twins are not born exactly at
  283. the same time).  However, the word "age" is frequently used to denote the
  284. number of years since birth.  For example, I am the same age as my wife,
  285. even though technically she is a few months older than I am.  And using the
  286. word "youngest" to mean "of lesser age" is also in keeping with common parlance.
  287. So I think the solution is fine as stated.
  288.  
  289. In the sum-13 variant, the possibilities are:
  290.  
  291. 11  1  1
  292. 10  2  1
  293. 9  3  1
  294. 9  2  2
  295. 8  4  1
  296. 8  3  2
  297. 7  5  1
  298. 7  4  2
  299. 7  3  3
  300. 6  6  1
  301. 6  5  2
  302. 6  4  3
  303.  
  304. The two that remain are 9 2 2 and 6 6 1 (both products equal 36).  The
  305. final bit of info (oldest child) indicates that there is only one
  306. child with the highest age.  This cancels out the 6 6 1 combination, leaving
  307. the childern with ages of 9, 2, and 2.
  308.  
  309. ==> logic/condoms.p <==
  310. How can you have mutually safe sex with three women with only two condoms?
  311.  
  312. ==> logic/condoms.s <==
  313. Use both condoms on the first woman.  Take off the outer condom (turning it
  314. inside-out in the process) and set it aside.  Use the inner condom alone on
  315. the second woman.  Put the outer condom back on.  Use it on the third woman.
  316.  
  317. ==> logic/dell.p <==
  318. How can I solve logic puzzles (e.g., as published by Dell) automatically?
  319.  
  320. ==> logic/dell.s <==
  321. #include    <setjmp.h>
  322.  
  323. #define    EITHER        if (S[1] = S[0], ! setjmp((S++)->jb)) {
  324. #define    OR        } else EITHER
  325. #define    REJECT        longjmp((--S)->jb, 1)
  326. #define    END_EITHER    } else REJECT;
  327.  
  328. /* values in tmat: */
  329. #define    T_UNK    0
  330. #define    T_YES    1
  331. #define    T_NO    2
  332.  
  333. #define    Val(t1,t2)    (S->tmat[t1][t2])
  334. #define    CLASS(x)        \
  335.         (((x) / NUM_ITEM) * NUM_ITEM)
  336. #define    EVERY_TOKEN(x)        \
  337.         (x = 0; x < TOT_TOKEN; x++)
  338. #define    EVERY_ITEM(x, class)    \
  339.         (x = CLASS(class); x < CLASS(class) + NUM_ITEM; x++)
  340.  
  341. #define    BEGIN                        \
  342. struct state {                        \
  343.     char    tmat[TOT_TOKEN][TOT_TOKEN];        \
  344.     jmp_buf jb;                    \
  345. } States[100], *S = States;                \
  346.                             \
  347. main()                            \
  348. {                            \
  349.     int    token;                    \
  350.                             \
  351.     for EVERY_TOKEN(token)                \
  352.         yes(token, token);            \
  353.     EITHER
  354.  
  355. /* Here is the problem-specific data */
  356. #define    NUM_ITEM    5
  357. #define    NUM_CLASS    6
  358. #define    TOT_TOKEN    (NUM_ITEM * NUM_CLASS)
  359.  
  360. #define    HOUSE_0        0
  361. #define    HOUSE_1        1
  362. #define    HOUSE_2        2
  363. #define    HOUSE_3        3
  364. #define    HOUSE_4        4
  365.  
  366. #define    ENGLISH        5
  367. #define    SPANISH        6
  368. #define    NORWEG        7
  369. #define    UKRAIN        8
  370. #define    JAPAN        9
  371.  
  372. #define    GREEN        10
  373. #define    RED        11
  374. #define    IVORY        12
  375. #define    YELLOW        13
  376. #define    BLUE        14
  377.  
  378. #define    COFFEE        15
  379. #define    TEA        16
  380. #define    MILK        17
  381. #define    OJUICE        18
  382. #define    WATER        19
  383.  
  384. #define    DOG        20
  385. #define    SNAIL        21
  386. #define    FOX        22
  387. #define    HORSE        23
  388. #define    ZEBRA        24
  389.  
  390. #define    OGOLD        25
  391. #define    PLAYER        26
  392. #define    CHESTER        27
  393. #define    LSTRIKE        28
  394. #define    PARLIA        29
  395.  
  396. char *names[] = {
  397.     "HOUSE_0", "HOUSE_1", "HOUSE_2", "HOUSE_3", "HOUSE_4",
  398.     "ENGLISH", "SPANISH", "NORWEG", "UKRAIN", "JAPAN",
  399.     "GREEN", "RED", "IVORY", "YELLOW", "BLUE",
  400.     "COFFEE", "TEA", "MILK", "OJUICE", "WATER",
  401.     "DOG", "SNAIL", "FOX", "HORSE", "ZEBRA",
  402.     "OGOLD", "PLAYER", "CHESTER", "LSTRIKE", "PARLIA",
  403. };
  404.  
  405.     BEGIN
  406.  
  407.     yes(ENGLISH, RED);    /* Clue 1 */
  408.     yes(SPANISH, DOG);    /* Clue 2 */
  409.     yes(COFFEE, GREEN);    /* Clue 3 */
  410.     yes(UKRAIN, TEA);    /* Clue 4 */
  411.  
  412.     EITHER            /* Clue 5 */
  413.         yes(IVORY, HOUSE_0);
  414.         yes(GREEN, HOUSE_1);
  415.     OR
  416.         yes(IVORY, HOUSE_1);
  417.         yes(GREEN, HOUSE_2);
  418.     OR
  419.         yes(IVORY, HOUSE_2);
  420.         yes(GREEN, HOUSE_3);
  421.     OR
  422.         yes(IVORY, HOUSE_3);
  423.         yes(GREEN, HOUSE_4);
  424.     END_EITHER
  425.  
  426.     yes(OGOLD, SNAIL);    /* Clue 6 */
  427.     yes(PLAYER, YELLOW);    /* Clue 7 */
  428.     yes(MILK, HOUSE_2);    /* Clue 8 */
  429.     yes(NORWEG, HOUSE_0);    /* Clue 9 */
  430.  
  431.     EITHER            /* Clue 10 */
  432.         yes(CHESTER, HOUSE_0);
  433.         yes(FOX, HOUSE_1);
  434.     OR
  435.         yes(CHESTER, HOUSE_4);
  436.         yes(FOX, HOUSE_3);
  437.     OR
  438.         yes(CHESTER, HOUSE_1);
  439.         EITHER    yes(FOX, HOUSE_0);
  440.         OR    yes(FOX, HOUSE_2);
  441.         END_EITHER
  442.     OR
  443.         yes(CHESTER, HOUSE_2);
  444.         EITHER    yes(FOX, HOUSE_1);
  445.         OR    yes(FOX, HOUSE_3);
  446.         END_EITHER
  447.     OR
  448.         yes(CHESTER, HOUSE_3);
  449.         EITHER    yes(FOX, HOUSE_2);
  450.         OR    yes(FOX, HOUSE_4);
  451.         END_EITHER
  452.     END_EITHER
  453.  
  454.     EITHER            /* Clue 11 */
  455.         yes(PLAYER, HOUSE_0);
  456.         yes(HORSE, HOUSE_1);
  457.     OR
  458.         yes(PLAYER, HOUSE_4);
  459.         yes(HORSE, HOUSE_3);
  460.     OR
  461.         yes(PLAYER, HOUSE_1);
  462.         EITHER    yes(HORSE, HOUSE_0);
  463.         OR    yes(HORSE, HOUSE_2);
  464.         END_EITHER
  465.     OR
  466.         yes(PLAYER, HOUSE_2);
  467.         EITHER    yes(HORSE, HOUSE_1);
  468.         OR    yes(HORSE, HOUSE_3);
  469.         END_EITHER
  470.     OR
  471.         yes(PLAYER, HOUSE_3);
  472.         EITHER    yes(HORSE, HOUSE_2);
  473.         OR    yes(HORSE, HOUSE_4);
  474.         END_EITHER
  475.     END_EITHER
  476.  
  477.     yes(LSTRIKE, OJUICE);    /* Clue 12 */
  478.     yes(JAPAN, PARLIA);    /* Clue 13 */
  479.  
  480.     EITHER            /* Clue 14 */
  481.         yes(NORWEG, HOUSE_0);
  482.         yes(BLUE, HOUSE_1);
  483.     OR
  484.         yes(NORWEG, HOUSE_4);
  485.         yes(BLUE, HOUSE_3);
  486.     OR
  487.         yes(NORWEG, HOUSE_1);
  488.         EITHER    yes(BLUE, HOUSE_0);
  489.         OR    yes(BLUE, HOUSE_2);
  490.         END_EITHER
  491.     OR
  492.         yes(NORWEG, HOUSE_2);
  493.         EITHER    yes(BLUE, HOUSE_1);
  494.         OR    yes(BLUE, HOUSE_3);
  495.         END_EITHER
  496.     OR
  497.         yes(NORWEG, HOUSE_3);
  498.         EITHER    yes(BLUE, HOUSE_2);
  499.         OR    yes(BLUE, HOUSE_4);
  500.         END_EITHER
  501.     END_EITHER
  502.  
  503. /* End of problem-specific data */
  504.  
  505.         solveit();
  506.     OR
  507.         printf("All solutions found\n");
  508.         exit(0);
  509.     END_EITHER
  510. }
  511.  
  512. no(a1, a2)
  513. {
  514.     int    non1, non2, token;
  515.  
  516.     if (Val(a1, a2) == T_YES)
  517.         REJECT;
  518.     else if (Val(a1, a2) == T_UNK) {
  519.         Val(a1, a2) = T_NO;
  520.         no(a2, a1);
  521.         non1 = non2 = -1;
  522.  
  523.         for EVERY_ITEM(token, a1)
  524.             if (Val(token, a2) != T_NO)
  525.                 if (non1 == -1)
  526.                     non1 = token;
  527.                 else
  528.                     break;
  529.         if (non1 == -1)
  530.             REJECT;
  531.         else if (token == CLASS(a1) + NUM_ITEM)
  532.             yes(non1, a2);
  533.  
  534.         for EVERY_TOKEN(token)
  535.             if (Val(token, a1) == T_YES)
  536.                 no(a2, token);
  537.     }
  538. }
  539.  
  540. yes(a1, a2)
  541. {
  542.     int    token;
  543.  
  544.     if (Val(a1, a2) == T_NO)
  545.         REJECT;
  546.     else if (Val(a1, a2) == T_UNK) {
  547.         Val(a1, a2) = T_YES;
  548.         yes(a2, a1);
  549.         for EVERY_ITEM(token, a1)
  550.             if (token != a1)
  551.                 no(token, a2);
  552.         for EVERY_TOKEN(token)
  553.             if (Val(token, a1) == T_YES)
  554.                 yes(a2, token);
  555.             else if (Val(token, a1) == T_NO)
  556.                 no(a2, token);
  557.     }
  558. }
  559.  
  560. solveit()
  561. {
  562.     int    token, tok2;
  563.  
  564.     for EVERY_TOKEN(token)
  565.         for (tok2 = token; tok2 < TOT_TOKEN; tok2++)
  566.             if (Val(token, tok2) == T_UNK) {
  567.                 EITHER
  568.                     yes(token, tok2);
  569.                 OR
  570.                     no(token, tok2);
  571.                 END_EITHER;
  572.                 return solveit();
  573.             }
  574.     printf("Solution:\n");
  575.     for EVERY_ITEM(token, 0) {
  576.         for (tok2 = NUM_ITEM; tok2 < TOT_TOKEN; tok2++)
  577.             if (Val(token, tok2) == T_YES)
  578.                 printf("\t%s %s\n",names[token],names[tok2]);
  579.         printf("\n");
  580.     }
  581.     REJECT;
  582. }
  583.  
  584. ---
  585. james@crc.ricoh.com (James Allen)
  586.  
  587. ==> logic/elimination.p <==
  588. 97 baseball teams participate in an annual state tournament.
  589. The way the champion is chosen for this tournament is by the same old
  590. elimination schedule. That is, the 97 teams are to be divided into
  591. pairs, and the two teams of each pair play against each other.
  592. After a team is eliminated from each pair, the winners would
  593. be again divided into pairs, etc.  How many games must be played
  594. to determine a champion?
  595.  
  596. ==> logic/elimination.s <==
  597. In order to determine a winner all but one team must lose.
  598. Therefore there must be at least 96 games.
  599.  
  600. ==> logic/family.p <==
  601. Suppose that it is equally likely for a pregnancy to deliver
  602. a baby boy as it is to deliver a baby girl.  Suppose that for a
  603. large society of people, every family continues to have children
  604. until they have a boy, then they stop having children.
  605. After 1,000 generations of families, what is the ratio of males
  606. to females?
  607.  
  608. ==> logic/family.s <==
  609. The ratio will be 50-50 in both cases.  We are not killing off any
  610. fetuses or babies, and half of all conceptions will be male, half
  611. female.  When a family decides to stop does not affect this fact.
  612.  
  613. ==> logic/flip.p <==
  614. How can a toss be called over the phone (without requiring trust)?
  615.  
  616. ==> logic/flip.s <==
  617. A flips a coin.  If the result is heads, A multiplies 2 90-digit prime
  618. numbers; if the result is tails, A multiplies 3 60-digit prime
  619. numbers.  A tells B the result of the multiplication.  B now calls
  620. either heads or tails and tells A.  A then supplies B with the
  621. original numbers to verify the flip.
  622.  
  623. ==> logic/friends.p <==
  624. Any group of 6 or more contains either 3 mutual friends or 3 mutual strangers.
  625. Prove it.
  626.  
  627. ==> logic/friends.s <==
  628. Take a person X.  Of the five other people, there must either be at least three
  629. acquaintances of X or at least three strangers of X.  Assume wlog that X has
  630. three strangers A,B,C.  Unless A,B,C is the required triad of acquaintances,
  631. they must include a pair of strangers, wlog A,B.  Then X,A,B is the required
  632. triad of strangers, QED.
  633.  
  634. ==> logic/hundred.p <==
  635. A sheet of paper has statements numbered from 1 to 100.  Statement n says
  636. "exactly n of the statements on this sheet are false."  Which statements are
  637. true and which are false?  What if we replace "exactly" by "at least"?
  638.  
  639. ==> logic/hundred.s <==
  640. It is tempting to argue as follows:
  641.  
  642. Since only one statement can be true (they are mutually contradictory),
  643. therefore 99 are false. So, all are false except for statement 99.
  644.  
  645. If replaced by "at least", and the "real" number of false statements is
  646. x, then statements x+1 to 100 will be false (since they falsely claim
  647. that there are more false statements than there actually are). So, 100-x are
  648. false, ie.  x=100-x, so x=50. The first 50 statements are true, and statements
  649. 51 to 100 are false.
  650.  
  651. However, there is a hidden and incorrect assumption in this argument.
  652. To see this, suppose that there is one statement on the sheet and it
  653. says "One statement is false"  or "At least one statement is false,"
  654. either way it implies "this statement is false," which is a familiar
  655. paradoxical statement.  We have learned that this paradox arises because
  656. of the false assumption that all statements are either true or false.
  657. This is the hidden assumption in the above reasoning.
  658.  
  659. If it is acknowledged that some of the statements on the page may be
  660. neither true nor false (i.e., meaningless), then nothing whatsoever can
  661. be concluded about which statements are true or false.
  662.  
  663. This problem has been carefully contrived to appear to be solvable (like
  664. the vacuous statement "this statement is true").  By changing the
  665. numbers in some statements and changing "true" to "false," various
  666. circular forms of the liar's paradox can be constructed.
  667.  
  668. From _Litton's Problematical Recreations_
  669.  
  670. ==> logic/inverter.p <==
  671. Can a digital logic circuit with two inverters invert N independent inputs?
  672. The circuit may contain any number of AND or OR gates.
  673.  
  674. ==> logic/inverter.s <==
  675. It can be shown that N inverters can invert 2N-1 independent inputs, given
  676. an unlimited supply of AND and OR gates. The classic version of this
  677. puzzle is to invert 3 independent inputs using AND gates, OR gates, and
  678. only 2 inverters.
  679.  
  680. So, start with N inverters.  Replace 3 of them with 2.
  681. Keep doing that until you're down to 2 inverters.
  682.  
  683. I was skeptical at first, because such a design requires so much feedback
  684. that I was sure the system would oscillate when switching between two
  685. particular states.  But after writing a program to test every possible state
  686. change (32^2), it appears that this system settles after a maximum of
  687. 3 feedback logic iterations. I did not include gate delays in the simulation,
  688. however, which could increase the number of iterations before the system
  689. settles.
  690.  
  691. In any case, it appears that the world needs only 2 inverters! :-)
  692.  
  693. ==> logic/josephine.p <==
  694. The recent expedition to the lost city of Atlantis discovered scrolls
  695. attributted to the great poet, scholar, philosopher Josephine. They
  696. number eight in all, and here is the first.
  697.  
  698. THE KINGDOM OF MAMAJORCA, WAS RULED BY QUEEN HENRIETTA I. IN MAMAJORCA
  699. WOMEN HAVE TO PASS AN EXTENSIVE LOGIC EXAM BEFORE THEY ARE ALLOWED TO
  700. GET MARRIED. QUEENS DO NOT HAVE TO TAKE THIS EXAM. ALL THE WOMEN IN
  701. MAMAJORCA ARE LOYAL TO THEIR QUEEN AND DO WHATEVER SHE TELLS THEM TO.
  702. THE QUEENS OF MAMAJORCA ARE TRUTHFUL. ALL SHOTS FIRED IN MAMAJORCA CAN
  703. BE HEARD IN EVERY HOUSE. ALL ABOVE FACTS ARE KNOWN TO BE COMMON
  704. KNOWLEDGE.
  705.  
  706. HENRIETTA WAS WORRIED ABOUT THE INFIDELITY OF THE MARRIED MEN IN
  707. MAMAJORCA.  SHE SUMMONED ALL THE WIVES TO THE TOWN SQUARE, AND MADE
  708. THE FOLLOWING ANNOUNCEMENT. "THERE IS AT LEAST ONE UNFAITHFUL HUSBAND
  709. IN MAMAJORCA. ALL WIVES KNOW WHICH HUSBANDS ARE UNFAITHFUL, BUT HAVE
  710. NO KNOWLEDGE ABOUT THE FIDELITY OF THEIR OWN HUSBAND. YOU ARE
  711. FORBIDDEN TO DISCUSS YOUR HUSBAND'S FAITHFULNESS WITH ANY OTHER WOMAN.
  712. IF YOU DISCOVER THAT YOUR HUSBAND IS UNFAITHFUL, YOU MUST SHOOT HIM AT
  713. PRECISELY MIDNIGHT OF THE DAY YOU FIND THAT OUT."
  714.  
  715. THIRTY-NINE SILENT NIGHTS FOLLOWED THE QUEEN'S ANNOUNCEMENT. ON THE
  716. FORTIETH NIGHT, SHOTS WERE HEARD. QUEEN HENRIETTA I IS REVERED IN
  717. MAMAJORCAN HISTORY.
  718.  
  719. As with all philosophers Josephine doesn't provide the question, but leaves
  720. it implicit in his document. So figure out the questions - there are two -
  721. and answer them.
  722.  
  723. Here is Josephine's second scroll.
  724.  
  725. QUEEN HENRIETTA I WAS SUCCEEDED BY DAUGHTER QUEEN HENRIETTA II. AFTER
  726. A WHILE HENRIETTA LIKE HER FAMOUS MOTHER BECAME WORRIED ABOUT THE
  727. INFIDELITY PROBLEM. SHE DECIDED TO ACT, AND SENT A LETTER TO HER
  728. SUBJECTS (WIVES) THAT CONTAINED THE EXACT WORDS OF HENRIETTA I'S
  729. FAMOUS SPEECH.  SHE ADDED THAT THE LETTERS WERE GUARENTEED TO REACH
  730. ALL WIVES EVENTUALLY.
  731.  
  732. QUEEN HENRIETTA II IS REMEMBERED AS A FOOLISH AND UNJUST QUEEN.
  733.  
  734. What is the question and answer implied by this scroll?
  735.  
  736. ==> logic/josephine.s <==
  737. The two questions for scroll #1 were:
  738.  
  739. 1. How many husbands were shot on that fateful night?
  740. 2. Why is Queen Henrietta I revered in Mamajorca?
  741.  
  742. The answers are:
  743.  
  744. If there are n unfaithful husbands (UHs), every wife of an UH knows of
  745. n-1 UH's while every wife of a faithful husband knows of n UHs.  [this
  746. because everyone has perfect information about everything except the
  747. fidelity of their own husband].  Now we do a simple induction: Assume
  748. that there is only one UH.  Then all the wives but one know that there
  749. is just one UH, but the wife of the UH thinks that everyone is
  750. faithful.  Upon hearing that "there is at least one UH", the wife
  751. realizes that the only husband it can be is her own, and so shoots
  752. him.  Now, imagine that there are just two UH's.  Each wife of an UH
  753. assumes that the situation is "only one UH in town" and so waits to
  754. hear the other wife (she knows who it is, of course) shoot her husband
  755. on the first night.  When no one is shot, that can only be because her
  756. OWN husband was a second UH.  The wife of the second UH makes the same
  757. deduction when no shot is fired the first night (she was waiting, and
  758. expecting the other to shoot, too).  So they both figure it out after
  759. the first night, and shoot their husbands the second night.  It is
  760. easy to tidy up the induction to show that the n UHs will all be shot
  761. just on the n'th midnight.
  762.  
  763. The question for scroll #2 is:
  764.  
  765. 3. Why is Queen Henrietta II not?
  766.  
  767. The answer is:
  768.  
  769. The problem now is that QHII didn't realize that it is *critical* that
  770. all of the wives, of faithful and UH's alike, to
  771. *BEGIN*AT*THE*SAME*MOMENT*.  The uncertainty of having a particular
  772. wife's notice come a day or two late makes the whole logic path fall
  773. apart.  That's why she's foolish.  She is unjust, because some wives,
  774. honed and crack logicians all, remember, will *incorrectly* shoot
  775. faithful husbands.  Let us imagine the situation with just a SINGLE UH
  776. in the whole country.  And, wouldn't you know it, the notice to the
  777. wife of the UH just happens to be held up a day, whereas everyone
  778. else's arrived the first day.  Now, all of the wives that got the
  779. notice the first day know that there is just one UH in the country.
  780. And they know that the wife of that UH will think that everyone is
  781. faithful, and so they'll expect her to figure it out and shoot her
  782. husband the first night.  BUT SHE DIDN"T GET THE NOTICE THE FIRST
  783. NIGHT....  BUT THE OTHER WIVES HAVE NO WAY OF KNOWING THAT.  So, the
  784. wife of the UH doesn't know that anything is going on and so (of
  785. course) doesn't do anything the first night.  The next day she gets
  786. the notice, figures it all out, and her husband will be history come
  787. that midnight.  BUT... *every* other wife thought that there should
  788. have been a shooting the first night, and since there wasn't there
  789. must have been an additional UH, and it can only have been _her_
  790. husband.  So on the second night **ALL** of the husbands are shot.
  791. Things are much more complicated if the mix of who gets the notice
  792. when is less simple than the one I mentioned above, but it is always
  793. wrong and/or tragic.
  794.  
  795. NOTE: if the wives *know* that the country courier service (or however
  796. these things get delivered) is flaky, then they can avoid the
  797. massacre, but unless the wives exchange notes no one will ever be shot
  798. (since there is always a chance that rather than _your_ husband being
  799. an UH, you could reason that it might be that the wife of one of the
  800. UH's that you know about just hasn't gotten her copy of the scroll
  801. yet).  I guess you could call this case "unjust", too, since the UH's
  802. evade punishment, despite the perfect logic of the wives.
  803.